package com.xiaoq.distribution.producer;

import com.xiaoq.coms.util.JsonUtil;
import com.xiaoq.distribution.vo.OrderTicketRequestVo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by chenjh on 2018/6/22.
 */
@Component
public class DistributionPublish {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendDistributionMsg(OrderTicketRequestVo orderTicketRequestVo){
        if (orderTicketRequestVo == null){
            return;
        }

        String msg = JsonUtil.asString(orderTicketRequestVo);
        rabbitTemplate.convertAndSend("deliver.queue.distribution", msg);
    }

}
